<?php

namespace slinks\extensions\amf\orm;

/**
 * 
 * @author Navid Mitchell
 *
 */

class PersistentCollectionProxy{
	
	public $_explicitType = 'slinks.extensions.amf.orm.PersistentCollectionProxy';
	
	private $owner;
	
	private $association;
	
	private $typeClass;
	
	private $dirty;
	
	private $isInitialized;
	
	private $source;
	
	
	/**
	 * Construct a Proxy for Doctrine persistent collections. 
	 * 
	 * @param \Doctrine\ORM\PersistentCollection $collection
	 */
	public function __construct(&$collection=null){
		if(isSet($collection)){
			$this->owner = $collection->getOwner();
			$this->association = $collection->getMapping();
			$this->typeClass = $collection->getTypeClass();
			$this->dirty = $collection->isDirty();
			$this->isInitialized = $collection->isInitialized();
			// only get if already initialized. Otherwise we send over for lazy initialization.
			if($collection->isInitialized()){
				$this->source = $collection->toArray();
			}else{
				$this->source = array();
			}
		}
	}

	/**
	 * 
	 * @return 
	 */
	public function getOwner()
	{
	    return $this->owner;
	}

	/**
	 * 
	 * @param $owner
	 */
	public function setOwner($owner)
	{
	    $this->owner = $owner;
	}

	/**
	 * 
	 * @return 
	 */
	public function getAssociation()
	{
	    return $this->association;
	}

	/**
	 * 
	 * @param $association
	 */
	public function setAssociation($association)
	{
	    $this->association = $association;
	}

	/**
	 * 
	 * @return 
	 */
	public function getTypeClass()
	{
	    return $this->typeClass;
	}

	/**
	 * 
	 * @param $typeClass
	 */
	public function setTypeClass($typeClass)
	{
	    $this->typeClass = $typeClass;
	}

	/**
	 * 
	 * @return 
	 */
	public function getDirty()
	{
	    return $this->dirty;
	}

	/**
	 * 
	 * @param $dirty
	 */
	public function setDirty($dirty)
	{
	    $this->dirty = $dirty;
	}


	/**
	 * 
	 * @return 
	 */
	public function getSource()
	{
	    return $this->source;
	}

	/**
	 * 
	 * @param $source
	 */
	public function setSource($source)
	{
	    $this->source = $source;
	}

	public function getIsInitialized()
	{
	    return $this->isInitialized;
	}

	public function setIsInitialized($isInitialized)
	{
	    $this->isInitialized = $isInitialized;
	}
}


